<?php

namespace App\Http\Middleware;

use Closure;
use App\Facades\Services\DoctorService;

class Register
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        $doctor = DoctorService::getDoctor();

        if ($doctor == null || count($doctor->wechatDoctorInfo) == 0) {
            return redirect('/doctor/defeated');
        }

        return $next($request);
    }
}
